/**
 * 
 */
package com.qmerak.common;

import java.io.File;

/**
 * @author shaohong.cheng
 * @date 2012-9-6
 */
public class SystemUtil {

	public static String getCurrentPath() {
		return System.getProperty("user.dir");
	}

	public static String getWebRootPath() {
		String pathString = SystemUtil.class.getResource("").getPath();
		File pathFile = new File(pathString).getParentFile().getParentFile().getParentFile().getParentFile();
		return pathFile.getParentFile().getPath();
	}

	public static File createPath(String path) {
		File dir = new File(path);
		if (dir.exists()) {
			return dir;
		}
		if (dir.getParent() != null) {
			createPath(dir.getParent());
		}
		if (dir.mkdir()) {
			return dir;
		}
		return null;
	}

	public static void main(String[] args) {
		System.out.println(getWebRootPath());
	}

}
